<div class="refine-search-by">
        	Refine Search by

        </div>
        <div class="refine-search-options">
          <div class="filter-boxes">
		  	<div class="refine-search-category">Cities</div>
                          <div class="refine-search-filters">
                            <%@cities=''%>
                            <%@counter=0%>
                            <%@advertisments.each do |ad| -%>

                            <%@cities=@cities+ad.university.city.id.to_s+', ' -%>
                            <%end -%>
                            <%@cities=@cities+'0' -%>
                            <%@cities=City.find_by_sql("select *  from cities where id in (#{@cities}) ")%>
                            <%@count=1%>
                            <%@a=@cities.collect{|x| [x.name, Advertisment.find_with_sphinx("#{@location} #{@cityname}   #{@categoryname}  #{@universityname} #{@keyword} @cityname(#{x.name})", :sphinx => {:mode => :extended, :limit => 1500}).length]}.sort{|x,y| y[1] <=> x[1]}%>
                            <%#@advertisments.each do |ad| -%>
                            <%#=h ad.university.city.name-%>
                            <%@a.each do |a|%>
                            <%if @counter<5%>
                            <%=link_to a[0].to_s+ " ("+ a[1].to_s+")",{:cityname=>a[0],:keyword=>params[:keyword],:location=>params[:location]}-%><br />
                            <%@counter=@counter+1%>
                            <%end -%>
                            <%end -%>
                          
                        <div style="float:right;align:right;"><%=link_to  h("More"),"#",:onclick=>"general_search_more('"+url_for(:controller=>"modelwindow",:action => "more_cities",:location=>params[:location],:keyword=>params[:keyword])+"');" -%>
                             <%=link_to  image_tag("read-more.jpg", :width=>"6px", :height=>"7px",:border=>"0px"), "#" -%>
                        </div>
                       </div>
              
          </div>

                  <div class="filter-boxes">
		  	<div class="refine-search-category">Universities</div>
                          <div class="refine-search-filters">
                            <%@universities=''%>
                            <%@counter=0%>
                            <%@advertisments.each do |ad| -%>
                            <%@universities=@universities+ad.university.id.to_s+', ' -%>
                            <%end -%>
                            <%@universities=@universities+'0' -%>
                            <%@universities=University.find_by_sql("select *  from universities where id in (#{@universities}) ")%>
                            <%@count=1%>
                            <%@a=@universities.collect{|x| [x.name, Advertisment.find_with_sphinx("#{@location} #{@cityname}   #{@categoryname}  #{@universityname} #{@keyword} @universityname(#{x.name})", :sphinx => {:mode => :extended, :limit => 1500}).length]}.sort{|x,y| y[1] <=> x[1]}%>
                            <%#@advertisments.each do |ad| -%>
                            <%#=h ad.university.city.name-%>
                            <%@a.each do |a|%>
                             <%if @counter<5%>
                             <%=link_to a[0].to_s+ " ("+ a[1].to_s+")",{:universityname=>a[0],:keyword=>params[:keyword],:location=>params[:location]}-%><br />
                             <%@counter=@counter+1%>
                            <%end -%>
                            <%end -%>
                               <div style="float:right;align:right;"><%=link_to  h("More"),"#",:onclick=>"general_search_more('"+url_for(:controller=>"modelwindow",:action => "more_universities",:location=>params[:location],:keyword=>params[:keyword])+"');" -%>
                             <%=link_to  image_tag("read-more.jpg", :width=>"6px", :height=>"7px",:border=>"0px"), "#" -%>
                        </div>
                          </div>
                       

          </div>


                  <div class="filter-boxes">
		  	<div class="refine-search-category">Categories</div>
                          <div class="refine-search-filters">
                            <%@categories=''%>
                            <%@counter=0%>
                            <%@advertisments.each do |ad| -%>
                            <%@categories=@categories+ad.sub_category.category.id.to_s+', ' -%>
                            <%end -%>
                            <%@categories=@categories+'0' -%>
                            <%@categories=Category.find_by_sql("select *  from categories where id in (#{@categories}) ")%>
                            <%@count=1%>
                            <%@a=@categories.collect{|x| [x.name, Advertisment.find_with_sphinx("#{@keyword} #{@location} #{@cityname}   #{@categoryname}  #{@universityname}  @categoryname(#{x.name})", :sphinx => {:mode => :extended, :limit => 1500}).length]}.sort{|x,y| y[1] <=> x[1]}%>
                            <%#@advertisments.each do |ad| -%>
                            <%#=h ad.university.city.name-%>
                            <%@a.each do |a|%>
                            <%if @counter<5%>
                            <%=link_to a[0].to_s+ " ("+ a[1].to_s+")",{:categoryname=>a[0],:keyword=>params[:keyword],:location=>params[:location]}-%><br />

                            <%@counter=@counter+1%>
                            <%end -%>
                            <%end -%>
                           </div>

          </div>

        </div>